
<section class="Hui-article-box">
    <nav class="breadcrumb">角色管理</nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <span class="l"> 
                    <a href="javascript:;" onclick="admin_add('添加角色', '/admin/manager/addrole', '800', '500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加角色</a> 
                </span>
            </div>
            <table class="table table-border table-bordered table-bg">
                <thead>
                    <tr>
                        <th scope="col" colspan="9">列表</th>
                    </tr>
                    <tr class="text-c">
                        <th width="40">ID</th>
                        <th width="90">名称</th>
                        <th width="130">创建时间</th>
                        <th width="100">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($datalist as $k=>$v){ ?>
                    <tr class="text-c">
                        <td>{$v['id']}</td>
                        <td><?=$v['name']?></td>
                        <td><?=$v['create_time']?></td>
                        <td class="td-manage">
                            <a onclick="admin_edit('角色编辑', '/admin/manager/addrole?id={$v['id']}', '1', '800', '500')"
                                class="ml-5 btn radius btn-primary">
                                 <i class="Hui-iconfont">&#xe6df;</i>编辑
                             </a> 
                             <a onclick="admin_del(this, {$v['id']})" class="btn radius btn-danger">
                                 <i class="Hui-iconfont">&#xe6e2;</i>删除
                             </a>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </article>
    </div>
</section>


<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript">
function admin_add(title,url,w,h){
    layer_show(title,url,w,h);
}
/*角色-删除*/
function admin_del(obj,id){
    layer.confirm('确认要删除吗？',function(index){
        //此处请求后台程序，下方是成功后的前台处理……
        $.get('/admin/manager/deleterole?id='+id).then(function(res){
            if(res.ret==0) {
                layer.msg(res.message,{icon:1,time:1000});
                $(obj).parents("tr").remove();
            }else{
                layer.msg(res.message);
            }
        })
        
    });
}
/*角色-编辑*/
function admin_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*角色-停用*/
function admin_stop(obj,id){
    layer.confirm('确认要停用吗？',function(index){
        //此处请求后台程序，下方是成功后的前台处理……

        $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
        $(obj).remove();
        layer.msg('已停用!',{icon: 5,time:1000});
    });
}

/*角色-启用*/
function admin_start(obj,id){
    layer.confirm('确认要启用吗？',function(index){
        //此处请求后台程序，下方是成功后的前台处理……
        $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,id)" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
        $(obj).remove();
        layer.msg('已启用!', {icon: 6,time:1000});
    });
}
</script> 
